package com.cmsr.springclond.controller;

import com.cmsr.springclond.common.*;
import com.cmsr.springclond.common.model.OrderCloseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/service/helloWeb")
    public String hello(){
        return "hello Controller..";
    }

    @Autowired(required = true)
    private OrderProcessService orderProcessService;

    /**
     * 订单关闭
     * @param orderCloseDto
     * @return
     */
    @RequestMapping(value = "/orderClose", method = RequestMethod.POST)
    public ResponseBase orderClose(@RequestBody OrderCloseDto orderCloseDto) {
        try {
            //参数校验
            Validators.validOcLengthAndRegex(orderCloseDto);
            //访问后台
            return ResponseResult.APISuccess(orderProcessService.orderClose(orderCloseDto));
        }catch (Exception e) {
            return ResponseFaild.failure("0000_0000_001", "执行失败");
        }
    }
}
